<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>消息设置</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="{__STATIC__}/layuiAdmin/layui/css/layui.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/adminui/dist/css/admin.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/style/style.css" rel="stylesheet">
</head>
<body>
<div class="layui-fluid">
	<form class="layui-form" style="padding-bottom: 45px;">
		<div class="layui-card">
			<div class="layui-card-body">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li class="layui-this">短信消息</li>
						<li>公众号消息</li>
						<li>小程序消息</li>
					</ul>
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							<div class="layui-form-item">
								<label class="layui-form-label">给会员发：</label>
								<div class="layui-input-block">
									<input type="checkbox" name="sms_user_pay" lay-filter="sms_user_pay" {eq name="$message.sms_user_pay" value="1"}checked{/eq} title="付款成功" value="1" lay-skin="primary">
									<input type="checkbox" name="sms_user_send" lay-filter="sms_user_send" {eq name="$message.sms_user_send" value="1"}checked{/eq} title="订单发货" value="1" lay-skin="primary">
									<input type="checkbox" name="sms_user_refund" lay-filter="sms_user_refund" {eq name="$message.sms_user_refund" value="1"}checked{/eq} title="退换结果" value="1" lay-skin="primary">
								</div>
							</div>
							<div class="layui-form-item" id="span_sms_user_pay" {eq name="$message.sms_user_pay" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">付款成功模板ID：</label>
								<div class="layui-input-inline">
									<input type="text" name="sms_user_pay_id" value="{$message.sms_user_pay_id}" placeholder="请输入付款成功模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux"><a href="https://console.topthink.com/sms/template" target="_blank">短信服务-模板管理中获取</a></div>
							</div>
							<div class="layui-form-item" id="span_sms_user_send" {eq name="$message.sms_user_send" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">订单发货模板ID：</label>
								<div class="layui-input-inline">
									<input type="text" name="sms_user_send_id" value="{$message.sms_user_send_id}" placeholder="请输入订单发货模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux"><a href="https://console.topthink.com/sms/template" target="_blank">短信服务-模板管理中获取</a></div>
							</div>
							<div class="layui-form-item" id="span_sms_user_refund" {eq name="$message.sms_user_refund" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">退换结果模板ID：</label>
								<div class="layui-input-inline">
									<input type="text" name="sms_user_refund_id" value="{$message.sms_user_refund_id}" placeholder="请输入退换结果模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux"><a href="https://console.topthink.com/sms/template" target="_blank">短信服务-模板管理中获取</a></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">给商家发：</label>
								<div class="layui-input-block">
									<input type="checkbox" name="sms_store_pay" lay-filter="sms_store_pay" {eq name="$message.sms_store_pay" value="1"}checked{/eq} title="下单通知" value="1" lay-skin="primary">
									<input type="checkbox" name="sms_store_refund" lay-filter="sms_store_refund" {eq name="$message.sms_store_refund" value="1"}checked{/eq} title="退换通知" value="1" lay-skin="primary">
								</div>
							</div>
							<div class="layui-form-item" id="span_sms_store_pay" {eq name="$message.sms_store_pay" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">下单通知模板ID：</label>
								<div class="layui-input-inline">
									<input type="text" name="sms_store_pay_id" value="{$message.sms_store_pay_id}" placeholder="请输入下单通知模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux"><a href="https://console.topthink.com/sms/template" target="_blank">短信服务-模板管理中获取</a></div>
							</div>
							<div class="layui-form-item" id="span_sms_store_refund" {eq name="$message.sms_store_refund" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">退换通知模板ID：</label>
								<div class="layui-input-inline">
									<input type="text" name="sms_store_refund_id" value="{$message.sms_store_refund_id}" placeholder="请输入退换通知模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux"><a href="https://console.topthink.com/sms/template" target="_blank">短信服务-模板管理中获取</a></div>
							</div>
						</div>
                        <!--公众号-->
						<div class="layui-tab-item">
							<div class="layui-form-item">
								<label class="layui-form-label">给会员发：</label>
								<div class="layui-input-block">
									<input type="checkbox" name="gzh_user_pay" lay-filter="gzh_user_pay" {eq name="$message.gzh_user_pay" value="1"}checked{/eq} title="付款成功" value="1" lay-skin="primary">
									<input type="checkbox" name="gzh_user_send" lay-filter="gzh_user_send" {eq name="$message.gzh_user_send" value="1"}checked{/eq} title="订单发货" value="1" lay-skin="primary">
									<input type="checkbox" name="gzh_user_refund" lay-filter="gzh_user_refund" {eq name="$message.gzh_user_refund" value="1"}checked{/eq} title="退换结果" value="1" lay-skin="primary">
								</div>
							</div>
							<div class="layui-form-item" id="span_gzh_user_pay" {eq name="$message.gzh_user_pay" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">付款成功模板ID：</label>
								<div class="layui-input-inline" style="width: 380px;">
									<input type="text" name="gzh_user_pay_id" value="{$message.gzh_user_pay_id}" placeholder="请输入付款成功模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">公众号后台-模板消息中获取</div>
							</div>
							<div class="layui-form-item" id="span_gzh_user_send" {eq name="$message.gzh_user_send" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">订单发货模板ID：</label>
								<div class="layui-input-inline" style="width: 380px;">
									<input type="text" name="gzh_user_send_id" value="{$message.gzh_user_send_id}" placeholder="请输入订单发货模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">公众号后台-模板消息中获取</div>
							</div>
							<div class="layui-form-item" id="span_gzh_user_refund" {eq name="$message.gzh_user_refund" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">退换结果模板ID：</label>
								<div class="layui-input-inline" style="width: 380px;">
									<input type="text" name="gzh_user_refund_id" value="{$message.gzh_user_refund_id}" placeholder="请输入退换结果模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">公众号后台-模板消息中获取</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">给商家发：</label>
								<div class="layui-input-block">
									<input type="checkbox" name="gzh_store_pay" lay-filter="gzh_store_pay" {eq name="$message.gzh_store_pay" value="1"}checked{/eq} title="下单通知" value="1" lay-skin="primary">
									<input type="checkbox" name="gzh_store_refund" lay-filter="gzh_store_refund" {eq name="$message.gzh_store_refund" value="1"}checked{/eq} title="退换通知" value="1" lay-skin="primary">
								</div>
							</div>
							<div class="layui-form-item" id="span_gzh_store_pay" {eq name="$message.gzh_store_pay" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">下单通知模板ID：</label>
								<div class="layui-input-inline" style="width: 380px;">
									<input type="text" name="gzh_store_pay_id" value="{$message.gzh_store_pay_id}" placeholder="请输入下单通知模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">公众号后台-模板消息中获取</div>
							</div>
							<div class="layui-form-item" id="span_gzh_store_refund" {eq name="$message.gzh_store_refund" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">退换通知模板ID：</label>
								<div class="layui-input-inline" style="width: 380px;">
									<input type="text" name="gzh_store_refund_id" value="{$message.gzh_store_refund_id}" placeholder="请输入退换通知模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">公众号后台-模板消息中获取</div>
							</div>
						</div>

						<div class="layui-tab-item">
							<div class="layui-form-item">
								<label class="layui-form-label">给会员发：</label>
								<div class="layui-input-block">
									<input type="checkbox" name="miniapp_user_pay" lay-filter="miniapp_user_pay" {eq name="$message.miniapp_user_pay" value="1"}checked{/eq} title="付款成功" value="1" lay-skin="primary">
									<input type="checkbox" name="miniapp_user_send" lay-filter="miniapp_user_send" {eq name="$message.miniapp_user_send" value="1"}checked{/eq} title="订单发货" value="1" lay-skin="primary">
									<input type="checkbox" name="miniapp_user_refund" lay-filter="miniapp_user_refund" {eq name="$message.miniapp_user_refund" value="1"}checked{/eq} title="退换结果" value="1" lay-skin="primary">
								</div>
							</div>
							<div class="layui-form-item" id="span_miniapp_user_pay" {eq name="$message.miniapp_user_pay" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">付款成功模板ID：</label>
								<div class="layui-input-inline" style="width: 380px;">
									<input type="text" name="miniapp_user_pay_id" value="{$message.miniapp_user_pay_id}" placeholder="请输入付款成功模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">小程序后台-订阅消息中获取</div>
							</div>
							<div class="layui-form-item" id="span_miniapp_user_send" {eq name="$message.miniapp_user_send" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">订单发货模板ID：</label>
								<div class="layui-input-inline" style="width: 380px;">
									<input type="text" name="miniapp_user_send_id" value="{$message.miniapp_user_send_id}" placeholder="请输入订单发货模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">小程序后台-订阅消息中获取</div>
							</div>
							<div class="layui-form-item" id="span_miniapp_user_refund" {eq name="$message.miniapp_user_refund" value="0"}style="display: none"{/eq}>
								<label class="layui-form-label">退换结果模板ID：</label>
								<div class="layui-input-inline" style="width: 380px;">
									<input type="text" name="miniapp_user_refund_id" value="{$message.miniapp_user_refund_id}" placeholder="请输入退换结果模板ID" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">小程序后台-订阅消息中获取</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="m_footer">
			<button class="layui-btn layui-btn-normal" lay-submit lay-filter="LAY-submit">提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</form>
</div>
</body>
</html>
<script src="{__STATIC__}/layuiAdmin/layui/layui.js"></script>
<script>
	layui.config({
		base: '{__STATIC__}/layuiAdmin/' // 静态资源所在路径
	}).use(['index','form'], function(){
		let $ = layui.$;
		let layer = layui.layer;
		let form = layui.form;

		form.on('checkbox(sms_user_pay)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_sms_user_pay').show();
			} else {
				$('#span_sms_user_pay').hide();
			}
		});
		form.on('checkbox(sms_user_send)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_sms_user_send').show();
			} else {
				$('#span_sms_user_send').hide();
			}
		});
		form.on('checkbox(sms_user_refund)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_sms_user_refund').show();
			} else {
				$('#span_sms_user_refund').hide();
			}
		});
		form.on('checkbox(sms_store_pay)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_sms_store_pay').show();
			} else {
				$('#span_sms_store_pay').hide();
			}
		});
		form.on('checkbox(sms_store_refund)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_sms_store_refund').show();
			} else {
				$('#span_sms_store_refund').hide();
			}
		});
		//公众号
		form.on('checkbox(gzh_user_pay)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_gzh_user_pay').show();
			} else {
				$('#span_gzh_user_pay').hide();
			}
		});
		form.on('checkbox(gzh_user_send)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_gzh_user_send').show();
			} else {
				$('#span_gzh_user_send').hide();
			}
		});
		form.on('checkbox(gzh_user_refund)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_gzh_user_refund').show();
			} else {
				$('#span_gzh_user_refund').hide();
			}
		});
		form.on('checkbox(gzh_store_pay)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_gzh_store_pay').show();
			} else {
				$('#span_gzh_store_pay').hide();
			}
		});
		form.on('checkbox(gzh_store_refund)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_gzh_store_refund').show();
			} else {
				$('#span_gzh_store_refund').hide();
			}
		});
		//小程序
		form.on('checkbox(miniapp_user_pay)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_miniapp_user_pay').show();
			} else {
				$('#span_miniapp_user_pay').hide();
			}
		});
		form.on('checkbox(miniapp_user_send)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_miniapp_user_send').show();
			} else {
				$('#span_miniapp_user_send').hide();
			}
		});
		form.on('checkbox(miniapp_user_refund)', function(data){
			let elem = data.elem;
			if(elem.checked) {
				$('#span_miniapp_user_refund').show();
			} else {
				$('#span_miniapp_user_refund').hide();
			}
		});

		/* 监听提交 */
		form.on('submit(LAY-submit)', function(data){
			let field = data.field; //获取提交的字段
			let sms_user_pay = field.hasOwnProperty('sms_user_pay') ? field.sms_user_pay : 0;
			let sms_user_send = field.hasOwnProperty('sms_user_send') ? field.sms_user_send : 0;
			let sms_user_refund = field.hasOwnProperty('sms_user_refund') ? field.sms_user_refund : 0;
			let sms_store_pay = field.hasOwnProperty('sms_store_pay') ? field.sms_store_pay : 0;
			let sms_store_refund = field.hasOwnProperty('sms_store_refund') ? field.sms_store_refund : 0;
			let gzh_user_pay = field.hasOwnProperty('gzh_user_pay') ? field.gzh_user_pay : 0;
			let gzh_user_send = field.hasOwnProperty('gzh_user_send') ? field.gzh_user_send : 0;
			let gzh_user_refund = field.hasOwnProperty('gzh_user_refund') ? field.gzh_user_refund : 0;
			let gzh_store_pay = field.hasOwnProperty('gzh_store_pay') ? field.gzh_store_pay : 0;
			let gzh_store_refund = field.hasOwnProperty('gzh_store_refund') ? field.gzh_store_refund : 0;
			let miniapp_user_pay = field.hasOwnProperty('miniapp_user_pay') ? field.miniapp_user_pay : 0;
			let miniapp_user_send = field.hasOwnProperty('miniapp_user_send') ? field.miniapp_user_send : 0;
			let miniapp_user_refund = field.hasOwnProperty('miniapp_user_refund') ? field.miniapp_user_refund : 0;
			$.ajax({
				type:"post",
				url:"saveMessage.html",
				data: {
					sms_user_pay:sms_user_pay,
					sms_user_send:sms_user_send,
					sms_user_refund:sms_user_refund,
					sms_user_pay_id:field.sms_user_pay_id,
					sms_user_send_id:field.sms_user_send_id,
					sms_user_refund_id:field.sms_user_refund_id,
					sms_store_pay:sms_store_pay,
					sms_store_refund:sms_store_refund,
					sms_store_pay_id:field.sms_store_pay_id,
					sms_store_refund_id:field.sms_store_refund_id,
					gzh_user_pay:gzh_user_pay,
					gzh_user_send:gzh_user_send,
					gzh_user_refund:gzh_user_refund,
					gzh_user_pay_id:field.gzh_user_pay_id,
					gzh_user_send_id:field.gzh_user_send_id,
					gzh_user_refund_id:field.gzh_user_refund_id,
					gzh_store_pay:gzh_store_pay,
					gzh_store_refund:gzh_store_refund,
					gzh_store_pay_id:field.gzh_store_pay_id,
					gzh_store_refund_id:field.gzh_store_refund_id,
					miniapp_user_pay:miniapp_user_pay,
					miniapp_user_send:miniapp_user_send,
					miniapp_user_refund:miniapp_user_refund,
					miniapp_user_pay_id:field.miniapp_user_pay_id,
					miniapp_user_send_id:field.miniapp_user_send_id,
					miniapp_user_refund_id:field.miniapp_user_refund_id,
				},
				dataType:"json",
				beforeSend: function () {
					layer.load(1);
				},
				success:function(res){
					layer.closeAll(); //关闭弹层
					if(res.code == 0){
						layer.msg('修改成功', {
							time: 2000
						}, function(){
							location.reload();
						});
					}
					else {
						layer.msg(res.msg);
					}
				}
			});
			return false;
		});
	});
</script>